// for Emacs -*- c++ -*-


private:

// the message queue (owned by the EventProcessor)
MultiMessageQueue msgQueue;

// mapping of message types to processing functions
typedef map< int, msgProcessor > ProcessorMap;
ProcessorMap processorsMap;


// keep track of thread structures started to stop threads in destructor
vector< pthread_t* > vThreads;

// variable to keep track how many threads exited the Spin()i
// needed to determine when it is safe to signal the processes waiting j
// to know when the EventProcessor died
volatile unsigned int finishedSpins;

// bool variable set by the Die message to cleanly finish the spin of the
// thread executing it
// declared volatile so that the compiler does not optimize it
// it could change at any time
volatile bool exitSpin;

///////////
// Facilities to wait for the event processor to die

pthread_cond_t died; // conditional variable that signals the death of the event processor
pthread_mutex_t diedMtx; // the mutex required for the variable to work

/////////////
// Helper functions

// helper function to start a thread running Spin()
// the argument passed is the pointer to the EventProcessor on which Spin is executed
static void* ForkAndSpinThread(void*);


// Start the event processing loop. This goes forever but does not do 
// busy wayting
// everybody should use ForkAndSpin instead of Spin to start a thread running the Spin()
void Spin(void);


